package com.sinoglobal.sinostore.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sinoglobal.sinostore.R;
import com.sinoglobal.sinostore.bean.CityVo;

public class CityAdapter extends BaseAdapter {
	private Context context;
	private List<CityVo> data;
	
	public CityAdapter(Context context,List<CityVo> data){
		this.context = context;
		this.data = data;
	}
	
	public void addList(List<CityVo> data){
		if(null == data){
			return;
		}
		for(CityVo cityVo : data){
			this.data.add(cityVo);
		}
		notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return this.data.size();
	}

	@Override
	public CityVo getItem(int position) {
		// TODO Auto-generated method stub
		return this.data.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup viewGroup) {
		if(null == convertView){
			convertView = LayoutInflater.from(context).inflate(R.layout.shop_city_listview_item, null);
		}
		TextView city = ViewHolder.getViewById(convertView, R.id.cityName);
		CityVo cityVo = getItem(position);
		city.setText(cityVo.getCityName());
		return convertView;
	}

}
